package com.mb.note.controller;


import com.lijian.common.domain.R;
import com.lijian.common.util.MinioUtil;
import io.swagger.annotations.ApiModel;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author LiJian
 * @date 2024-10-29
 */
@ApiModel(description = "上传管理接口")
@RestController
@RequestMapping("/file")
public class FileUploadController {

    @Resource
    private MinioUtil minioUtil;

    @PostMapping("/upload")
    public String upload(@RequestParam("file") MultipartFile multipartFile) {
        return minioUtil.upload(multipartFile);
    }

    @PostMapping("/download")
    public void download(@RequestParam("fileName") String fileName, HttpServletResponse response) {
        minioUtil.fileDownload(fileName, false, response);
    }

}
